const path = require("path")


// __dirname 与porcess.cwd() 返回的路径都是命令行执行的路径
module.exports = {
    entry: './main.js',//入口
    output: {
        filename: "bundle.js", //打包后的文件名称 [name] 默认是main.js
        path: path.resolve(__dirname, "dist") //打包后的文件路径
    },
    module: {
        rules: [
            {
                //处理.css结尾文件的loader
                test: /\.css$/i,
                use: ["style-loader", "css-loader"]
            },
            {
                test: /\.(png|svg|jpg|jpeg|gif)$/i,
                type: "asset/resource"
            },
            {
                test: /\.(woff|woff2|eot|ttf|otf)$/i,
                type: 'asset/resource',
            },
            {
                test: /\.(csv|tsv)$/i,
                use: ['csv-loader'],
            },
            {
                test: /\.xml$/i,
                use: ['xml-loader'],
            },
            {
                test: /\.toml$/i,
                type: 'json',
                parser: {
                    // parse: toml.parse,
                },
            },
            {
                test: /\.yaml$/i,
                type: 'json',
                parser: {
                    // parse: yaml.parse,
                },
            },
            {
                test: /\.json5$/i,
                type: 'json',
                parser: {
                    // parse: json5.parse,
                },
            },
        ]
    }
}



